//package elitech.vietnam.weatherfashion.tabs.settings;
//
//import java.io.IOException;
//import java.util.ArrayList;
//
//import android.app.ProgressDialog;
//import android.content.BroadcastReceiver;
//import android.content.Context;
//import android.content.Intent;
//import android.os.AsyncTask;
//import android.os.Bundle;
//import android.support.v4.app.Fragment;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.view.ViewGroup;
//import android.widget.Button;
//import elitech.vietnam.weatherfashion.R;
//import elitech.vietnam.weatherfashion.WFApplication;
//import elitech.vietnam.weatherfashion.config.GlobalValue;
//import elitech.vietnam.weatherfashion.dto.FriendDTO;
//import elitech.vietnam.weatherfashion.dto.MemberDTO;
//import elitech.vietnam.weatherfashion.service.PHPSoapServiceCaller;
//
//public class FriendListFragment extends Fragment {
//
////	private ListView lvFriend;
//	private AdapterFriendListListView adapterFiendList;
//	private ArrayList<FriendDTO> listFriend;
//	private ProgressDialog mProgressDialog;
//	private Button btnBack;
//	private Intent intentFromService;
//
//	@Override
//	public View onCreateView(LayoutInflater inflater, ViewGroup container,
//			Bundle savedInstanceState) {
//		View view = inflater.inflate(R.layout.fragment_friend_list, null);
//
//		initView(view);
//		return view;
//	}
////
////	private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
////		@Override
////		public void onReceive(Context context, Intent intent) {
////			boolean counter = intent.getBooleanExtra("RELOAD_DONE", false);
////			if (counter) {
////				try {
////					// updateUI
////					adapterFiendList
////							.reloadData(WFApplication.getInstance().userFriends);
////					adapterFiendList.notifyDataSetChanged();
////				} catch (Exception e) {
////				}
////			}
////		}
////	};
//
//	@Override
//	public void onResume() {
//		super.onResume();
//		// intentFromService = new Intent(getActivity(),
//		// ReloadFriendListService.class);
//		// getActivity().startService(intentFromService);
//		// getActivity().registerReceiver(broadcastReceiver,
//		// new IntentFilter(ReloadFriendListService.BROADCAST_ACTION));
//	}
//
//	@Override
//	public void onStop() {
//		super.onStop();
//		// getActivity().unregisterReceiver(broadcastReceiver);
//		// getActivity().stopService(intentFromService);
//	}
//
//	private void initView(View view) {
//		/****************** s **************/
//		btnBack = (Button) view.findViewById(R.id.btnBack);
//		btnBack.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				// getFragmentManager()
//				// .beginTransaction()
//				// .replace(R.id.container_framelayout,
//				// new SettingsFragment()).commit();
//				getActivity().onBackPressed();
//			}
//		});
//
//		/******************************/
////		lvFriend = (ListView) view.findViewById(R.id.lvFriendList);
//
//		/********************************/
//		mProgressDialog = new ProgressDialog(getActivity());
//		mProgressDialog.setTitle(this.getResources().getString(
//				R.string.setting_friend_list_title_process));
//		mProgressDialog.setMessage(this.getResources().getString(
//				R.string.setting_change_password_processing));
//		mProgressDialog.setCancelable(false);
//
//		/*******************************/
//		MemberDTO user = GlobalValue.getInstance(getActivity()).readUserInfo();
//		// // load lai danh sach neu chua load bao h
//		// if (AppConfig.getInstance().userFriends == null
//		// || AppConfig.getInstance().userFriends.size() == 0) {
//
//		LoadListFriendAsynTask loadListFriendAsynTask = new LoadListFriendAsynTask();
//		loadListFriendAsynTask.execute(user.getId());
//		// } else {
//		//
//		// listFriend = (ArrayList<FriendDTO>)
//		// AppConfig.getInstance().userFriends;
//		// adapterFiendList = new AdapterFriendListListView(
//		// FriendListFragment.this.getActivity(), listFriend);
//		// lvFriend.setAdapter(adapterFiendList);
//		// }
//	}
//
//	private class LoadListFriendAsynTask extends
//			AsyncTask<Integer, Integer, ArrayList<FriendDTO>> {
//
//		@Override
//		protected ArrayList<FriendDTO> doInBackground(Integer... params) {
//
//			int userId = params[0];
//
//			PHPSoapServiceCaller serviceCaller = new PHPSoapServiceCaller();
//			try {
//				listFriend = serviceCaller.getListFriend(userId);
//			} catch (IOException e) {
//				e.printStackTrace();
//				if (listFriend == null)
//					listFriend = new ArrayList<FriendDTO>();
//			}
//
//			// ArrayList<FriendDTO> abc;
//			// GlobalValue.getInstance(getActivity()).writeFriendList(listFriend);
//			// abc = GlobalValue.getInstance(getActivity()).readFriendList();
//
//			return listFriend;
//		}
//
//		@Override
//		protected void onPostExecute(ArrayList<FriendDTO> result) {
//			// TODO Auto-generated method stub
//			super.onPostExecute(result);
//			mProgressDialog.dismiss();
//			WFApplication.getInstance().userFriends = result;
//			listFriend = result;
//			adapterFiendList = new AdapterFriendListListView(
//					FriendListFragment.this.getActivity(), listFriend);
////			lvFriend.setAdapter(adapterFiendList);
//		}
//
//		@Override
//		protected void onPreExecute() {
//			// TODO Auto-generated method stub
//			super.onPreExecute();
//			mProgressDialog.show();
//		}
//	}
//}
